package com.youedata.modular.enums;

public enum LevelFlag {
    /**
     * 等级枚举
     */
    PRIMARY("00", "初级"),
    MIDDLE("01", "中级"),
    HIGH("02", "高级");

    private String code;
    private String desc;

    LevelFlag(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static LevelFlag getByCode(String code) {
        LevelFlag[] values = values();
        for (LevelFlag sw : values) {
            if (sw.code.equals(code)) {
                return sw;
            }
        }
        return null;
    }

    public static LevelFlag getByDesc(String desc) {
        LevelFlag[] values = values();
        for (LevelFlag sw : values) {
            if (sw.desc.equals(desc)) {
                return sw;
            }
        }
        return null;
    }

    public static Boolean checkCode(String code) {
        LevelFlag[] values = values();
        for (LevelFlag sw : values) {
            if (sw.code.equals(code)) {
                return true;
            }
        }
        return false;
    }


    public static Boolean checkDesc(String desc) {
        LevelFlag[] values = values();
        for (LevelFlag sw : values) {
            if (sw.desc.equals(desc)) {
                return true;
            }
        }
        return false;
    }
}
